<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <textarea cols="30" rows="10"></textarea>
    <script>
        let t = document.getElementsByTagName("textarea")[0];
        t.addEventListener('keyup', (e) => {
            console.log(calculate(e.target.value));
        })

        function calculate(s) {
            s = s.split('');
            let cnt = 0;
            s.forEach((item) => {
                if (item == '\n' || item == ' ') {
                    return;
                }
                if (item.charCodeAt() >= 19968 && item.charCodeAt() <= 40869 || item.charCodeAt() >= 97 && item.charCodeAt() <= 122 || item.charCodeAt() >= 65 && item.charCodeAt() <= 90 || item >= 0 && item <= 9) {
                    cnt++;
                }
            })
            return cnt;
        }
    </script>
</body>

</html>